<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function Stu(name) {
        this.name = name
    }
    Stu.prototype.say = function () {
        console.log("千束")
    }

    // Man 使用 Stu的属性和方法
    function Man(n) {
        Stu.call(this, n)
        this.age = 16
    }
    Man.prototype = Stu.prototype//原型继承
    let o2 = new Man("ln")
    console.log(o2)











    // 封装
    class Stu {
        constructor(name) {//构造函数
            this.name = name
        }
        say() {
            console.log("泷奈")
        }
    }
    let o1 = new Stu("零零")
    o1.say()

    // 继承
    class Man extends Stu {//extends 继承 Man继承了Stu
        constructor(name) {//不能写这个  因为继承的时候 被继承的东西已经存在了constructor
            super(name) //指向继承的/父级的constructor 
            this.sex = "女"//想拥有自己的方法  需要写上面的那个super
        }
    }
    let o3 = new Man("奈")
    console.log(o3)
    o3.say
</script>

</html>